// pages/buyNow/buyNow.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    countdown_minutes:5,
    countdown_seconds:60,
    shopID:"",
    shopName:"扬州宝龙广场店",
    shopAddress:"邗江区维扬路27号宝金广场9栋1层134室",
    latitude:"",
    longitude:"",
    ordernum:"11111111111111",
    title:"生耶拿铁",
    specs:"冰/无糖",    //规格
    thumbnail:"../../images/ruixing12.jpg"

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that = this
    that.countDown();

    //当前店铺的shopID我存在缓存里面了，差一条协议，根据shopID查询店铺详情，店铺名，店铺地址，联系方式
    let shopid = wx.getStorage("shopID")
    that.setData({
      shopID:shopid
    })
    
  },

  //倒计时
  countDown() {
    var that = this
    var starttime = '2022/07/04 17:14:19'
    var start = new Date(starttime.replace(/-/g, "/")).getTime()
    var endTime = start + 5 * 60000

    var date = new Date(); //现在时间
    var now = date.getTime(); //现在时间戳

    var allTime = endTime - now
    var m, s;
    if (allTime > 0) {
      m = Math.floor(allTime / 1000 / 60 % 60);     
      s = Math.floor(allTime / 1000 % 60);    
      that.setData({       
        countdown_minutes:m,
        countdown_seconds:s,
         //countdown: m + "：" + s,
      })
      setTimeout(that.countDown, 1000);
    } else {
      console.log('已截止')
      // that.setData({
      //   countdown: '00:00'
      // })
    }
  },

  //点击图片跳转到优惠券页面
  getTickets:function(){
    let that = this
    wx.switchTab({    
      url: '../tickets/tickets',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})